﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Stema.Controls;
using Fluent;
using WpfNavigationPane;
using Abhiruchi_Phase1;
using System.Diagnostics;
using System.IO;

namespace NavigationPaneDemo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : RibbonWindow
    {
        Process p;
        public MainWindow()
        {
            InitializeComponent();
        }


        private void navigationPane_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            grdRightPane.Children.Clear();
        }

        private void NavigationPaneButton_Click(object sender, RoutedEventArgs e)
        {

        }

        //private void navigationPane_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        //{
        //    //grdRightPane.Children.Clear();
        //} 

        private void btnPermanent_Click(object sender, RoutedEventArgs e)
        {
            grdRightPane.Children.Clear();

            UC_HRM_PE_CE_MainWindow myTab = new UC_HRM_PE_CE_MainWindow("Permanent Employee");
            Image img = new Image();
            BitmapImage src = new BitmapImage();
            src.BeginInit();
            src.UriSource = new Uri(getPathofFile() + "//Images//person.ico", UriKind.Relative);
            src.CacheOption = BitmapCacheOption.OnLoad;

            src.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
            src.EndInit();
            myTab.image1.Source = src;

            grdRightPane.Children.Add(myTab);
        }

        private void btnContract_Click(object sender, RoutedEventArgs e)
        {

            grdRightPane.Children.Clear();
            UC_HRM_PE_CE_MainWindow myTab = new UC_HRM_PE_CE_MainWindow("Contract Employee");
            Image img = new Image();
            BitmapImage src = new BitmapImage();
            src.BeginInit();
            src.UriSource = new Uri(getPathofFile() + "//Images//operator.ico", UriKind.Relative);
            src.CacheOption = BitmapCacheOption.OnLoad;

            src.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
            src.EndInit();
            myTab.image1.Source = src;
            grdRightPane.Children.Add(myTab);
        }

        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            grdRightPane.Children.Clear();
            UC_HRM_EmpSearch mySearch = new UC_HRM_EmpSearch();
            grdRightPane.Children.Add(mySearch);
        }

        private void btnLoc_Click(object sender, RoutedEventArgs e)
        {
            grdRightPane.Children.Clear();
            UC_ORG_Location myLoc = new UC_ORG_Location();
            grdRightPane.Children.Add(myLoc);
        }

        private void btnSection_Click(object sender, RoutedEventArgs e)
        {
            grdRightPane.Children.Clear();
            UC_ORG_Section mySectn = new UC_ORG_Section();
            grdRightPane.Children.Add(mySectn);
        }
        private void btnTasks_Click(object sender, RoutedEventArgs e)
        {
            grdRightPane.Children.Clear();
            UC_ORG_TaskMaster myTasks = new UC_ORG_TaskMaster();
            grdRightPane.Children.Add(myTasks);
        }
        private void btntaskMap_Click(object sender, RoutedEventArgs e)
        {
            grdRightPane.Children.Clear();
            UC_ORG_TaskMapping myTaskMapping = new UC_ORG_TaskMapping();
            grdRightPane.Children.Add(myTaskMapping);
        }
        private string getPathofFile()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory;
            string[] pathArray = path.Split(new char[] { '\\' });
            path = string.Empty;
            for (int temp = 0; temp < pathArray.Count() - 3; temp++)
            {
                if (temp == 0)
                    path = path + pathArray[temp];
                else
                    path = path + "\\" + pathArray[temp];
            }

            return path;
        }


        public void GridClear()
        {
            grdRightPane.Children.Clear();
        }

        private void quickTaskMap_Click(object sender, RoutedEventArgs e)
        {
            btntaskMap_Click(null, null);
        }

        private void quickSearch_Click(object sender, RoutedEventArgs e)
        {
            btnSearch_Click(null, null);
        }

        private void Biometric_Click(object sender, RoutedEventArgs e)
        {
            string BioPath = @"F:\BiometricCompleateApplication\BiometricCompleateApplication\BiometricCompleateApplication\bin\Debug\BiometricCompleateApplication.exe";
            try
            {
                
                p = new Process();
                

                if (File.Exists(BioPath))
                {
                    p.Close();
                    p.StartInfo = new ProcessStartInfo(BioPath);
                    p.Start();
                }
                else
                {
                    MessageBox.Show("Biometric Application not Configured for this System", "Error", MessageBoxButton.OK,MessageBoxImage.Information);
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Error Occured", "Error", MessageBoxButton.OK,MessageBoxImage.Error);
            }
        }

        private void quickHelp_Click(object sender, RoutedEventArgs e)
        {
            string path = getPathofFile() + "/help/Help/index.html";
            HelpWindow hwObj = new HelpWindow(path);

            hwObj.ShowDialog();

        }

    }
}
